#!/bin/bash

APP_PATH="/mnt/sdb1/code-space/argostranslate"
LOG_FILE="$APP_PATH/server.log"
# worker 取决于你的服务器的CPU核数，一般设置为 4 左右
CMD="uv run uvicorn app.trans:app --host 0.0.0.0 --port 4141 --workers 4"

cd "$APP_PATH" || exit 1

echo "Stopping existing uvicorn processes..."
pkill -f "uvicorn app.trans:app"
sleep 3

echo "Starting uvicorn in background..."
nohup $CMD > "$LOG_FILE" 2>&1 &

echo "Done. Log: $LOG_FILE"
